package chenji.yourticket.model;

import org.bukkit.Material;
import org.bukkit.entity.Player;

import chenji.yourticket.Main;
import chenji.yourticket.inventory.SimpleInventory;
import chenji.yourticket.inventory.SimpleItemStack;

public class ActionChooseInventory extends SimpleInventory {
	private ModelInfo mi;
	private Player p;

	public ActionChooseInventory(Player p, ModelInfo m) {
		super(p, (short) 7, Main.getMessageManager().getAction_Title(), 3);
		this.mi = m;
		this.p = p;
		this.installItemStack();
	}

	@Override
	public void installItemStack() {
		this.getInventory().setItem(10,
				new SimpleItemStack(Material.INK_SACK,
						Main.getMessageManager().getItem_Press_Lore().replaceAll("%price%",
								Double.toString(Main.getMaterialManager().getPrice(this.mi.getItem().getType()))),
						Main.getMessageManager().getItem_Press_Title()));
		this.getInventory().setItem(16, new SimpleItemStack(Material.WRITTEN_BOOK,
				Main.getMessageManager().getItem_Edit_Lore(), Main.getMessageManager().getItem_Edit_Title()));
		this.getInventory().setItem(13, this.mi.getItem());

	}

	public void clickInventory(int slot) {

		if (slot == 10) {
			Main.getPressManager().openInventory(p, this.mi);
			return;
		}
		if (slot == 16) {
			Main.getEditorManager().edit(this.p, this.mi);
		}
	}

}
